package com.movitech.wechat;

import com.gson.bean.InMessage;
import com.gson.bean.OutMessage;
import com.gson.bean.TextOutMessage;
import com.gson.inf.MessageProcessingHandler;
import com.movitech.wechat.util.ConstantsUtil;
import com.movitech.wechat.util.Decoder;

public class WeChatMessageProcessingHandlerImpl
  implements MessageProcessingHandler
{
  private OutMessage outMessage;

  public void afterProcess(InMessage arg0, OutMessage arg1)
  {
  }

  public void allType(InMessage msg)
  {
  }

  public void eventTypeMsg(InMessage msg)
  {
    String event = msg.getEvent();
    TextOutMessage out = new TextOutMessage();
    if ((!event.equals(ConstantsUtil.SUBSCRIBE)) && (!event.equals(ConstantsUtil.CLICK)))
      return;
    out.setContent(ConstantsUtil.SUBSCRIBE_INFO);
    setOutMessage(out);
  }

  public OutMessage getOutMessage()
  {
    return this.outMessage;
  }

  public void imageTypeMsg(InMessage msg)
  {
    String qrcode = Decoder.decode(msg.getPicUrl());

    TextOutMessage out = new TextOutMessage();
    if (qrcode == null)
    {
      out.setContent("您查询的产品信息为:ABB 德逸 equip 10A二位单控开关 ");
    }

    setOutMessage(out);
  }

  public void linkTypeMsg(InMessage arg0)
  {
  }

  public void locationTypeMsg(InMessage arg0)
  {
  }

  public void setOutMessage(OutMessage outMessage)
  {
    this.outMessage = outMessage;
  }

  public void textTypeMsg(InMessage msg)
  {
    TextOutMessage out = new TextOutMessage();
    out.setContent(ConstantsUtil.SUBSCRIBE_INFO);
    setOutMessage(out);
  }

  public void videoTypeMsg(InMessage arg0)
  {
  }

  public void voiceTypeMsg(InMessage arg0)
  {
  }
}